package edu.buaa.act.travel.m.tpdl.moveaction;

import org.json.JSONException;
import org.json.JSONObject;


public class WalkAction extends MoveAction {
	public static final String TYPE = "walk";
	int length;

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}
	
	@Override
	protected JSONObject toJSONObject(){
		JSONObject o = super.toJSONObject();
		try {
			o.put("length", length);
			o.put("type", TYPE);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return o;
	}
	
	@Override
	public void fromJSON(JSONObject j) throws JSONException{
		super.fromJSON(j);
		this.setLength(j.getInt("length"));
	}
	
	@Override
	public String toString(){
		return "从 "+startPlace+ " 走到 "+endPlace;
	}
}
